package org.example.book.service.impl;

import org.example.book.entity.MyUserDetails;
import org.example.book.entity.User;
import org.example.book.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserDetailsService {
    @Autowired
    UserMapper userMapper;

    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException{
        User user= userMapper.getUserByUsername(username);

        String authorities ="";

        MyUserDetails userDetails=new MyUserDetails(user,authorities);
        return userDetails;
    }
}
